package grouplife::Controller::TuanZhuanYi;
use Moose;
use namespace::autoclean;
use Catalyst::Request::Upload;
use Catalyst::Log;
use grouplife::Model::Users::UsersSearchModel;
use grouplife::Model::Users::UserRegisterModel;
use grouplife::Model::News::MyNewsModel;
use grouplife::Model::Comments::CommentsForUsersModel;
use grouplife::Model::UserUser::UserUserModel;
use grouplife::Model::UserStore::UserStoreModel;
use grouplife::Model::Tuan::TuansSearchModel;
use grouplife::Model::CommentedItem::CommentedItemModel;
use grouplife::Model::University::UniversityModel;
use Util::Email::SendEmail;
use Digest::MD5;

BEGIN {extends 'Catalyst::Controller'; }
__PACKAGE__->config( 'Plugin::ConfigLoader' => { file => 'grouplife.yml' } );

=head1 NAME

grouplife::Controller::Users - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut


=head2 index

=cut

sub nofity_fahuo : Local {
        my ($self, $c) = @_;
	my $tuan_id = $c->request->params->{tuan_id}; 
	my $fa_address = $c->request->params->{fa_address}; 
	my $fa_time = $c->request->params->{fa_time}; 

	if (!$c->user_exists) {
		$c->response->redirect($c->uri_for('/login'));
		$c->flash->{redirect_after_login} = '' . $c->req->uri;
		return 0;
	}
	my $me_id = $c->user->id;

	my $fahuo_count = $c->model('TuanZhuanYi::TuanZhuanYiModel')->find_next_fahuo_count($tuan_id);
	$c->model('FaHuo::FaHuoModel')->add_to_fahuo($tuan_id,$fa_time,$fa_address,$fahuo_count,$me_id);
	
}

#################################################################################
#fahuo information
#################################################################################
sub base :Chained('/') :PathPart('zhuanyi') :CaptureArgs(0) {
        my ($self, $c) = @_;
	$c->log->error(">>>>>>>>>>>>>.first method<<<<<<<<<<<<<<<<<<<<<<");
}

sub object :Chained('base') :PathPart('id') :CaptureArgs(1) {
        my ($self, $c, $id) = @_;
        $c->stash(object => $c->model('TuanZhuanYi::TuanZhuanYiModel')->find($id));
	$c->log->error(">>>>>>>>>>>>>second method<<<<<<<<<<<<<<<<<<<<<<".$id."<<<<<<<<<<<>>>>>>>>>>>");
        $c->stash(id => $id);
}

sub zhuanyi_info :Chained('object') :PathPart('zhuanyi_info') :Args(0) {
	my ($self, $c) = @_;

        $c->cache_page( $c->config->{time_out} );
        my $request = $c->model('TuanZhuanYi::TuanZhuanYiModel')->find($c->stash->{object}->id);
	$c->log->error(">>>>>>>>>>>>>third method<<<<<<<<<<<<<<<<<<<<<<".$request->id."<<<<<<<<<<<>>>>>>>>>>>");
        $c->stash(
                zhuanyi_request => $request,
                javascript => '/tuan/tuan_info.js',
                template => 'zhuanyi/zhuanyi_mainpage.tt2');
}


=head1 AUTHOR

lijie,,,

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

__PACKAGE__->meta->make_immutable;

1;
